/*
 * @Author: czy
 * @Date: 2021-04-29 20:00:06
 * @LastEditTime: 2021-04-30 14:38:38
 */
#include "mystdio.h"
/**
 * @description: Find the maximum number of the array and return it's index.
 * @param array The first address of the array.
 * @param len   Array length.
 * @return The index of the maximum number.
 */
int imax(int array[], int len)
{
    int index = 0;
    for (int i = 1; i < len; i++)
    {
        if (array[i] > array[i - 1])
        {
            index = i;
        }
    }
    return index;
}

/**
 * @description: Find the minimum number of the array and return it's index.
 * @param array The first address of the array.
 * @param len   Array length.
 * @return The index of the minimum number.
 */
int imin(int array[], int len)
{
    int index = 0;
    for (int i = 1; i < len; i++)
    {
        if (array[i] < array[i - 1])
        {
            index = i;
        }
    }
    return index;
}

/**
 * @description: Find the same value in the array.
 * @param result    Result array.
 * @param num       Result array length.
 * @param array     Source array.
 * @param len       Source array length.
 * @param value     Value.
 */
void arrayfind(int result[], int *num, int array[], int len, int value)
{
    *num = 0;
    for (int i = 0; i < len; i++)
    {
        if (array[i] == value)
        {
            result[*num] = i;
            (*num)++;
        }
    }
}
